#! /usr/bin/env python

"""
examples from http://www.codecho.com/how-to-use-args-and-kwargs-in-python
"""

def test_var_args(farg, *args):
    print "formal arg:", farg
    for arg in args:
        print "another arg:", arg

test_var_args(1, "two", 3)

def test_var_kwargs(farg, **kwargs):
    print "formal arg:", farg
    for key in kwargs:
        print "another keyword arg: %s: %s" % (key, kwargs[key])

test_var_kwargs(farg=1, myarg2="two", myarg3=3)

def test_var_args_call(arg1, arg2, arg3):
    print "arg1:", arg1
    print "arg2:", arg2
    print "arg3:", arg3

args = ("two", 3)
test_var_args_call(1, *args)

def test_var_args_call(arg1, arg2, arg3):
    print "arg1:", arg1
    print "arg2:", arg2
    print "arg3:", arg3

kwargs = {"arg3": 3, "arg2": "two"}
test_var_args_call(1, **kwargs)

#class Foo(object):
#    def __init__(self, value1, value2):
#        # do something with the values
#        print value1, value2
#
#class MyFoo(Foo):
#    def __init__(self, *args, **kwargs):
#        # do something else, don't care about the args
#        print 'myfoo'
#        super(MyFoo, self).__init__(*args, **kwargs)

mynum = 1000
mystr = 'Hello World!'
print "{mystr} New-style formatting is {mynum}x more fun!".format(**locals())
